package be.g00glen00b.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;

import com.googlecode.ehcache.annotations.Cacheable;

@Component
public class TwitterService {
	
	@Autowired
	private TwitterFactory factory;

	protected Twitter getTwitter() {
		return factory.getInstance();
	}
	
	@Cacheable(cacheName="cache")
	public List<Status> getTweets(String username) throws TwitterException {
		return getTwitter().getUserTimeline(username);
	}
}
